package skill;

public class singleNumber {
    public int singleNumber(int[] nums) {
        //异或操作
        if(nums.length==1){
            return nums[0];
        }
        int x=nums[0];
        for(int i=1;i<nums.length;i++){
            x=x^nums[i];
        }
        return x;
    }
    public static void main(String[] args) {
        singleNumber obj = new singleNumber();
        int[] nums = new int[]{4,4,6,1,2,1,2};
        System.out.println(obj.singleNumber(nums));
    }   
}
